autoprewarm worker failing to load

  • Jump to comment-1
    tharakan@gmail.com2022-07-27T14:48:52+00:00
    Hi, 089480c077056 seems to have broken pg_prewarm. When pg_prewarm is added to shared_preload_libraries, each new connection results in thousands of errors such as this: 2022-07-27 04:25:14.325 UTC [2903955] LOG: background worker "autoprewarm leader" (PID 2904146) exited with exit code 1 2022-07-27 04:25:14.325 UTC [2904148] ERROR: could not find function "autoprewarm_main" in file "/home/ubuntu/proj/tempdel/lib/postgresql/pg_prewarm.so" Checking pg_prewarm.so the function 'autoprewarm_main' visibility switched from GLOBAL to LOCAL. Per [1], using PGDLLEXPORT makes it GLOBAL again, which appears to fix the issue: Before commit (089480c077056) - ubuntu:~/proj/tempdel$ readelf -sW lib/postgresql/pg_prewarm.so | grep main 103: 0000000000003d79 609 FUNC GLOBAL DEFAULT 14 autoprewarm_main 109: 00000000000045ad 873 FUNC GLOBAL DEFAULT 14 autoprewarm_database_main 128: 0000000000003d79 609 FUNC GLOBAL DEFAULT 14 autoprewarm_main 187: 00000000000045ad 873 FUNC GLOBAL DEFAULT 14 autoprewarm_database_main After commit (089480c077056) - 78: 0000000000002d79 609 FUNC LOCAL DEFAULT 14 autoprewarm_main 85: 00000000000035ad 873 FUNC LOCAL DEFAULT 14 autoprewarm_database_main After applying the attached fix: 103: 0000000000003d79 609 FUNC GLOBAL DEFAULT 14 autoprewarm_main 84: 00000000000045ad 873 FUNC LOCAL DEFAULT 14 autoprewarm_database_main 129: 0000000000003d79 609 FUNC GLOBAL DEFAULT 14 autoprewarm_main Please let me know your thoughts on this approach. [1] https://www.postgresql.org/message-id/A737B7A37273E048B164557ADEF4A58B5393038C%40ntex2010a.host.magwien.gv.at diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c index b2d6026093..ec619be9f2 100644 --- a/contrib/pg_prewarm/autoprewarm.c +++ b/contrib/pg_prewarm/autoprewarm.c @@ -82,7 +82,7 @@ typedef struct AutoPrewarmSharedState int prewarmed_blocks; } AutoPrewarmSharedState; -void autoprewarm_main(Datum main_arg); +PGDLLEXPORT void autoprewarm_main(Datum main_arg); void autoprewarm_database_main(Datum main_arg); PG_FUNCTION_INFO_V1(autoprewarm_start_worker); - Robins Tharakan Amazon Web Services
    • Jump to comment-1
      tgl@sss.pgh.pa.us2022-07-27T15:16:46+00:00
      Robins Tharakan <tharakan@gmail.com> writes: > 089480c077056 seems to have broken pg_prewarm. Ugh ... sure would be nice if contrib/pg_prewarm had some regression tests. > Checking pg_prewarm.so the function 'autoprewarm_main' visibility > switched from GLOBAL to LOCAL. Per [1], using PGDLLEXPORT > makes it GLOBAL again, which appears to fix the issue: Right, that's the appropriate fix. I suppose we had better look at everything else that's passed to bgw_function_name anywhere, too. regards, tom lane